home *** CD-ROM | disk | FTP | other *** search
- ;-----------------------------------------------------------------------
- ; MODULE XDETECT
- ;
- ; Hardware detection module
- ;
- ; Compile with Tasm.
- ; C callable.
- ;
- ;
- ; ****** XLIB - Mode X graphics library ****************
- ; ****** ****************
- ; ****** Written By Themie Gouthas ****************
- ; ****** Aeronautical Research Laboratory ****************
- ; ****** Defence Science and Technology Organisation ****************
- ; ****** Australia ****************
- ;
- ; egg@dstos3.dsto.gov.au
- ; teg@bart.dsto.gov.au
- ;-----------------------------------------------------------------------
- LOCALS
- .286
-
- include model.inc
- include xdetect.inc
-
-
- .code
-
-
- i86 equ 0
- i186 equ 1
- i286 equ 2
- i386 equ 3
-
-
- NONE equ 0
- MDA equ 1
- CGA equ 2
- EGAMono equ 3
- EGAColor equ 4
- VGAMono equ 5
- VGAColor equ 6
- MCGAMono equ 7
- MCGAColor equ 8
-
- PS2_CARDS db 0,1,2,2,4,3,2,5,6,2,8,7,8
-
-
- ;-----------------------------------------------------------------------
- ; PC Graphics detection routine. Returns graphics card type
- ;
- ; C callable as:
- ; unsigned int x_graphics_card();
- ;
- ;
-
- proc _x_graphics_card
- push bp ; Preserve caller's stack frame
- mov ax,1A00h ; Try calling VGA Identity Adapter function
- int 10h
- cmp al,1Ah ; Do we have PS/2 video bios ?
- jne @@not_PS2 ; No!
-
- cmp bl,0Ch ; bl > 0Ch => CGA hardware
- jg @@is_CGA ; Jump if we have CGA
- xor bh,bh
- xor ah,ah
- mov al,cs:PS2_CARDS[bx] ; Load ax from PS/2 hardware table
- jmp short @@done ; return ax
- @@is_CGA:
- mov ax,CGA ; Have detected CGA, return id
- jmp short @@done
- @@not_PS2: ; OK We don't have PS/2 Video bios
- mov ah,12h ; Set alternate function service
- mov bx,10h ; Set to return EGA information
- int 10h ; call video service
- cmp bx,10h ; Is EGA there ?
- je @@simple_adapter ; Nop!
- mov ah,12h ; Since we have EGA bios, get details
- mov bl,10h
- int 10h
- or bh,bh ; Do we have colour EGA ?
- jz @@ega_color ; Yes
- mov ax,EGAMono ; Otherwise we have Mono EGA
- jmp short @@done
- @@ega_color:
- mov ax,EGAColor ; Have detected EGA Color, return id
- jmp short @@done
- @@simple_adapter:
- int 11h ; Lets try equipment determination service
- and al,30h
- shr al,4
- xor ah,ah
- or al,al ; Do we have any graphics card at all ?
- jz @@done ; No ? This is a stupid machine!
- cmp al,3 ; Do We have a Mono adapter
- jne @@is_CGA ; No
- mov ax,MDA ; Have detected MDA, return id
- @@done:
- pop bp ;restore caller's stack frame
- ret
- _x_graphics_card endp
-
-
- ;-----------------------------------------------------------------------
- ; PC Processor detection routine
- ;
- ; C callable as:
- ; unsigned int x_processor();
- ;
- ;
- proc _x_processor
- pushf ; Save flags
- xor ax,ax ; Clear AX
- push ax ; Push it on the stack
- popf ; Zero the flags
- pushf ; Try to zero bits 12-15
- pop ax ; Recover flags
- and ax,0F000h ; If bits 12-15 are 1 => i86 or i286
- cmp ax,0F000h
- jz is_86_186
-
- mov ax,07000h ; Try to set bits 12-14
- push ax
- popf
- pushf
- pop ax
- and ax,07000h ; If bits 12-14 are 0 => i286
- jz is_286
-
- mov ax,i386 ; We have a 386
- jmp short @@done
-
- is_286:
- mov ax,i286 ; We have a 286
- jmp short @@done
-
- is_86_186: ; Determine whether i86 or i186
- push cx ; save CX
- mov ax,0FFFFh ; Set all AX bits
- mov cl,33 ; Will shift once on 80186
- shl ax,cl ; or 33 x on 8086
- pop cx
- jnz is_186 ; 0 => 8086/8088
- is_86:
- mov ax,i86
- jmp short @@done
- is_186:
- mov ax,i186
- @@done:
- popf
- ret
- _x_processor endp
- end
-